package com.huiying.mapper;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.huiying.entity.dto.FollowPageQueryDTO;
import com.huiying.entity.entity.Follow;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @Author: lsh
 * @Date: 2024/11/01/21:22
 * @Description:
 */
@Mapper
public interface FollowMapper {
    @Insert("insert into follows(user_id, followee_id, create_time) values (#{userId}," +
            "#{followeeId},#{createTime})")
    void insert(Follow follow);

    @Delete("delete from follows where user_id = #{userId} and followee_id = #{followeeId}")
    void deleteByFolloweeId(Follow follow);

    Page<Follow> pageQuery(FollowPageQueryDTO followPageQueryDTO);

    @Select("select followee_id from follows where user_id = #{userId}")
    List<Long> list(Long userId);

    @Select("select user_id from follows where followee_id = #{userId}")
    List<Long> getFansList(Long userId);

    /**
     * 查询用户关注关系
     * @param userId
     * @param userId1
     * @return: com.fx.entity.Follow
     */
    @Select("select id, user_id, followee_id, create_time from follows where user_id = #{userId} and followee_id = #{userId1}")
    Follow getFollowByUserId(@Param("userId") Long userId,
                             @Param("userId1") Long userId1);
}
